package org.rsbot.loader.script.adapter;

import org.rsbot.loader.asm.ClassAdapter;
import org.rsbot.loader.asm.ClassVisitor;
import org.rsbot.loader.asm.MethodVisitor;

public class SetSignatureAdapter extends ClassAdapter
{
  private Signature[] signatures;

  public SetSignatureAdapter(ClassVisitor paramClassVisitor, Signature[] paramArrayOfSignature)
  {
    super(paramClassVisitor);
    this.signatures = paramArrayOfSignature;
  }

  public MethodVisitor visitMethod(int paramInt, String paramString1, String paramString2, String paramString3, String[] paramArrayOfString)
  {
    for (Signature localSignature : this.signatures) {
      if (((localSignature.name.equals(paramString1)) && (localSignature.desc.equals(""))) || (localSignature.desc.equals(paramString2))) {
        return this.cv.visitMethod(localSignature.new_access == -1 ? paramInt : localSignature.new_access, localSignature.new_name, localSignature.new_desc.equals("") ? paramString2 : localSignature.new_desc, paramString3, paramArrayOfString);
      }

    }

    return this.cv.visitMethod(paramInt, paramString1, paramString2, paramString3, paramArrayOfString);
  }

  public static class Signature
  {
    public String name;
    public String desc;
    public int new_access;
    public String new_name;
    public String new_desc;
  }
}